package cn.mayaslight.common.utils;

import java.lang.reflect.Type;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class JsonUtil {
	
	private JsonUtil(){}
	
	public static <T> T parseObject(String json,Class<T> clazz){
		Gson gson = new Gson();  
        return gson.fromJson(json, clazz);  
	}
	
	public static Map<String,String> parseMap(String json){
		Gson gson = new Gson();
		Type type = new TypeToken<Map<String, String>>() {}.getType();  
		return gson.fromJson(json, type);
	}

	public static String toJSONString(Object obj){
		Gson gson = new Gson();  
        return gson.toJson(obj);  
	}
}
